package fr.vvins.core.catalog.entity;


import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import fr.vvins.core.dao.EntityImpl;


/**
 * Tag entity
 */
@Entity
@Table(schema="vvins",name="VV_TAG")
public class Tag extends EntityImpl implements Serializable {

	private static final long serialVersionUID = 5168532042641127687L;
	@Id
	@GeneratedValue
	@Column(name="id")
	private Integer id;
	
	@Basic
	@Column(name="name")
	private String name;
	
	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(schema="vvins", name="VV_PRODUCT_TAG", joinColumns=@JoinColumn(name="TAG_ID"), inverseJoinColumns=@JoinColumn(name="PRODUCT_ID"))
	private Set<Product> product = new HashSet<Product>(0);

	@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
	@JoinTable(schema="vvins", name="VV_VIGNERON_TAG", joinColumns=@JoinColumn(name="TAG_ID"), inverseJoinColumns=@JoinColumn(name="VIGNERON_ID"))
	private Set<Vigneron> vignerons = new HashSet<Vigneron>(0);

	
	public Tag() {
	}

	public Tag(int id) {
		this.id = id;
	}

	public Tag(int id, String name, Set<Product> products) {
		this.id = id;
		this.name = name;
	}

	@Override
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<Product> getProduct() {
		return product;
	}

	public void setProduct(Set<Product> product) {
		this.product = product;
	}

	public Set<Vigneron> getVignerons() {
		return vignerons;
	}

	public void setVignerons(Set<Vigneron> vignerons) {
		this.vignerons = vignerons;
	}


}
